//
//  ViewController.m
//  18-SQLite
//
//  Created by mafeng on 16/8/8.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#import "Student.h"
#import "SQLiteDataBaseManager.h"
@interface ViewController ()
@property (nonatomic, strong) SQLiteDataBaseManager *dataBaseManager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
      _dataBaseManager = [SQLiteDataBaseManager sharedManager];
    // 注意: 使用时要引用libsqlite3.0.tbd
    // libsqlite3.0.tbd 和 libsqlite3.tbd的区别
    // libsqlite3.0.tbd 是 libsqlite3.tbd 的替身文件, 防止用户误删
}

- (IBAction)openSQLite:(id)sender {
    [_dataBaseManager openSQLite3];
    
}

- (IBAction)closeSQLite:(id)sender {
    [_dataBaseManager closeSQLite3];
}

- (IBAction)creatTable:(id)sender {
    [_dataBaseManager createTable];
}
- (IBAction)insertStu:(id)sender {
    Student *stu = [[Student alloc] init];
    stu.stu_name = @"XX";
    stu.stu_id = 22;
    [_dataBaseManager insertStu:stu];
}
- (IBAction)deleteStu:(id)sender {
    Student *stu = [[Student alloc] init];
    stu.stu_name = @"XX";
    stu.stu_id = 22;
    [_dataBaseManager deleteStu:stu];
}
- (IBAction)deleteAll:(id)sender {
    [_dataBaseManager deleteAll];
}
- (IBAction)updateName:(id)sender {
    [_dataBaseManager updateOldName:@"XX" newName:@"王道领"];
}
- (IBAction)selectAll:(id)sender {
    NSArray *array =[_dataBaseManager selectAll];
    NSLog(@"%@", array);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
